/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufba.lasid.v1.jitclouds.mda.datatypes.virtualization;

import br.ufba.lasid.v1.jitclouds.mda.datatypes.BasicMachine;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.GuestList;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.ICluster;
import br.ufba.lasid.v1.jitclouds.mda.datatypes.IGuest;

/**
 *
 * @author aliriosa
 */
public class BasicNode extends BasicMachine implements INode{
    
    private String endpoint = "localhost";
    private ICluster cluster = null;

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }
    
    

    @Override
    public IHypervisor getHypervisor(String idHypervisor) {
        return (IHypervisor) getGuest(idHypervisor);
    }

    @Override
    public void addHypervisor(String idHypervisor, IHypervisor hypervisor) {
        hypervisor.setHost(this);
        addGuest(idHypervisor, hypervisor);
    }

    @Override
    public void delHypervisor(String idHypervisor) {
        getHypervisor(idHypervisor).setHost(null);
        delGuest(idHypervisor);    
    }
    
    @Override
    public HypervisorList getHypervisors(){
        
        GuestList guests = getGuests();
        
        HypervisorList hypervisors = new HypervisorList();
        
        for(IGuest guest : guests){
            if(guest instanceof IHypervisor){
                hypervisors.add((IHypervisor)guest);
            }
        }
        
        return hypervisors;
        
    }

    @Override
    public void setCluster(ICluster cluster) {
        this.cluster = cluster;
    }

    @Override
    public ICluster getCluster() {
        return this.cluster;
    }
    
}
